<template>
	<view class="details">
		<view class="img">
			<image :src="detailsData.image" mode="aspectFill"></image>
		</view>
		<view class="details_content">
			<view class="title row2">{{detailsData.title}}</view>
			<view class="money">￥{{detailsData.price}}</view>
			<view class="time">
				<view class="time_left">有效期：</view>
				<view class="time_right" v-if="detailsData.course_type == 1">
					<!-- <text class="name">{{detailsData.course_ids}}</text> -->
					<view>{{detailsData.month}}个月</view>
				</view>
				<view class="time_right" v-else>
					<view v-for="(v, k) in detailsData.item" :key="k">
						<text class="name">{{v.title}}</text>
						<text>{{v.month}}个月</text>
					</view>
				</view>
			</view>
			<view class="introduce">详情介绍</view>
			<view class="details_introduce">
				<u-parse :html="detailsData.content"></u-parse>
				
			</view>
		</view>
		<view class="footer">
			<view class="total">
				<text>合计：</text>
				<text>￥{{detailsData.price}}</text>
			</view>
			<view :class="detailsData.is_buy == 0 ? 'college' : 'college1' " @tap="buyNow">立即购买</view>
			<!-- <view class="college" @tap="buyNow">立即购买</view> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1,
				id: '',
				detailsData: ''
			}
		},
		onLoad(option) {
			this.id = option.id
			uni.showLoading({
				title: '加载中'
			})
			this.detailsInfo()
		},
		onShow() {
			
		},
		methods: {
			detailsInfo() {
				this.$api.post(global.apiUrls.getCourseDetails, {
					id: this.id
				}).then(res => {
					// console.log(res)
					uni.hideLoading()
					if (res.data.code == 1) {
						this.detailsData = res.data.data
					} else {
						this.$message.info(res.data.msg)
					}
				})
			},
			// 立即购买
			buyNow() {
				if (this.detailsData.is_buy == 1) {
					this.$message.info('已购买过该课程')
				} else {
					uni.navigateTo({
						url: '/pages/study/confirmPurchase?image=' + this.detailsData.image + '&price=' + this.detailsData.price + '&title=' + this.detailsData.title + '&month=' + this.detailsData.month + '&id=' + this.detailsData.id + '&course_type=' + this.detailsData.course_type
					})
				}
			}
		}
		
	}
</script>

<style lang="scss" scoped>
	.details {
		.img {
			height: 500rpx;
			width: 100%;
			// background: skyblue;
			image {
				width: 100%;
				height: 100%;
			}
		}
		.details_content {
			padding: 32rpx 32rpx 132rpx;
			.title {
				font-weight: bold;
				margin-bottom: 36rpx;
			}
			.money {
				color: #FF3A3A;
				font-weight: bold;
			}
			.time {
				margin-top: 16rpx;
				font-size: 28rpx;
				display: flex;
				margin-bottom: 61rpx;
				.time_left {
					flex: 1.7;
				}
				.time_right {
					flex: 8.3;
					view {
						margin-bottom: 6rpx;
					}
					.name {
						margin-right: 20rpx;
					}
				}
			}
			.introduce {
				// margin-top: 28rpx;
				text-align: center;
				font-weight: 500;
				margin-bottom: 36rpx;
			}
			.details_introduce {
				.content1 {
					font-size: 28rpx;
					margin-bottom: 32rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 48rpx;
					color: #666666;
				}
				.content2 {
					font-size: 28rpx;
					margin-bottom: 24rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 48rpx;
					color: #666666;
					text:nth-child(1) {
						margin-right: 24rpx;
					}
				}
				.content3 {
					height: 334rpx;
					width: 100%;
					background-color: pink;
				}
			}
		}
		.footer {
			// display: flex;
			position: fixed;
			bottom: 0;
			width: 100%;
			height: 100rpx;
			background: #FFFFFF;
			box-shadow: 0px -1rpx 8rpx rgba(0, 0, 0, 0.1);
			opacity: 1;
			line-height: 100rpx;
			padding: 0 32rpx;
			padding-top: 14rpx;
			.total {
				padding-top: 0rpx !important;
				width: 300rpx;
				// height: 40rpx;
				transform: translateY(-10rpx);
				float: left;
				text:nth-child(1) {
					font-weight: 400;
				}
				text:nth-child(2) {
					color: #FF3A3A;
					font-weight: bold;
				}
			}
			.college {
				width: 210rpx;
				height: 72rpx;
				line-height: 72rpx;
				text-align: center;
				background: #267DFF;
				opacity: 1;
				border-radius: 36rpx;
				color: #FFFFFF;
				font-size: 28rpx;
				// margin: 0 40rpx 0 178rpx;
				float: right;
			}
			.college1 {
				width: 210rpx;
				height: 72rpx;
				line-height: 72rpx;
				text-align: center;
				background: #bfbfbf;
				opacity: 1;
				border-radius: 36rpx;
				color: #333333;
				font-size: 28rpx;
				// margin: 0 40rpx 0 178rpx;
				float: right;
			}
		}
	}
	
</style>
